<?php
include_once('../global.php');
$show = $_GET['show'];

$pl_id = $_GET['pl_id'];
$tm_id = $_GET['tm_id'];
$mt_id = 4164;


$roundtext = array(
	1 => '第一轮',
	2 => '第二轮',
	3 => '决赛轮',
	4 => '',
);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
	<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<link href="<?php echo CSS_PATH ?>index.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="<?php echo JS_PATH ?>jquery-1.8.3.min.js"></script>
	<script type="text/javascript" src="<?php echo JS_PATH ?>main.js"></script>
	<title>赛事公告-<?php echo $match_cn_name ?></title>
	<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js "></script>

	<script>
		const apiKey = 'e4b82bfdad4336f5ddc39122654ab44b'; // 获取OpenWeatherMap的API密钥
		// const city = 'Sanya,cn'; // 三亚的城市名称
		const city = 'Tangxia,Dongguan,cn'; // 塘厦镇的城市名称（包含更详细的位置）


		fetch(`https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${apiKey}&units=metric&lang=zh_cn`)
			.then(response => response.json())
			.then(data => {
				const weatherDescription = data.weather[0].description;
				const temperature = parseInt(data.main.temp);
				const humidity = data.main.humidity;
				const weatherInfo = `${temperature}°C，${weatherDescription}`;
				document.getElementById('weather-info').innerText = weatherInfo;
			})
			.catch(error => {
				document.getElementById('weather-info').innerText = '天气信息获取失败';
			});

		var url = location.href;
		var wxdata;
		//alert(url.split("&")[0]);
		//console.log(url.replace(/\&/g,"%26").replace(/\#/g,"%23"));
		$.ajax({
			type: "get",
			url: "../../interface/Bmwtnc/Home/gettoken/?url=" + encodeURIComponent(location.href.split('#')[0]),
			dataType: "jsonp",
			jsonp: "callback",
			jsonpCallback: "success_jsonpCallback",
			success: function(data) {
				//console.log(data);
				wxdata = data;
				wx.config({
					debug: false,
					appId: data.appId,
					timestamp: data.timestamp,
					nonceStr: data.nonceStr,
					signature: data.signature,
					jsApiList: [
						'onMenuShareTimeline', //
						'onMenuShareAppMessage',
						'onMenuShareQQ',
						'onMenuShareWeibo',
						'onMenuShareQZone'

					]
				});
				//console.log(wxdata);
			},
			error: function(data) {
				// alert("连接失败！");
			}
		});

		wx.ready(function() {
			var shareData = {
				title: '<?php echo $match_cn_name ?>-赛事公告',
				desc: '<?php echo $course_name ?>',
				link: url,
				imgUrl: 'https://mapp.scoringchina.com/bmwjunior/mobile/images/logo.png'
			};
			//alert(wxdata.url);
			//alert(url);
			wx.onMenuShareAppMessage(shareData); //分享给好友
			wx.onMenuShareTimeline(shareData); //分享到朋友圈
			wx.onMenuShareQQ(shareData); //分享给手机QQ
			wx.onMenuShareWeibo(shareData); //分享腾讯微博
			wx.onMenuShareQZone(shareData); //分享到QQ空间



		});
		wx.error(function(res) {
			//console.log(res);
			// alert(res.errMsg);//错误提示

		});




		function mygetnativeevent(event) {
			while (event && typeof event.originalEvent !== "undefined") {
				event = event.originalEvent;
			}
			return event;
		};
		$(document).ready(function() {
			////console.log($('.pullrefresh').length)
			if ($('.pullrefresh').length > 0) {
				//pullrefresh.init();
			}
		});

		var mt_id = <?php echo $mt_id; ?>;
		var rd_id = <?php echo $rd_id; ?>;
		var mt_sts = '<?php echo $mt_sts; ?>';
		var mt_round = <?php echo $mt_round; ?>;
		var pl_id = <?php echo ($_GET['pl_id']) ? $_GET['pl_id'] : "''"; ?>;

		var time = 60 * 5; //自动刷新五分钟
		getdata(rd_id, true);







		function getdata(rd, isloading, divobj, contentobj, status, func) {
			if (isloading) {
				//$('#loadingimg').show();
			}
			// //console.log(rd);
			$.ajax({
				url: './data/noticelist-data.php?time=' + Date.now() + '&mt_id=' + mt_id,
				dataType: "html",
				success: function(res) {
					////console.log(res)

					$("#scoringlists").html(res);




					////console.log(page);
				},
				complete: function() {
					if (func) {
						func();
					}
					//pullrefresh.init();


					if (isloading) {
						//$('#loadingimg').hide();
					}
				}
			})
		}

		function changeround(rd) {
			if (rd <= mt_round) {
				rd_id = rd;
				//getdata(rd_id);

				window.location = './index.php?mt_id=' + mt_id + '&rd_id=' + rd_id;
			}
		}


		function imgShow(url, urls) {
			// var currEl =$('#pinimg');
			// var url =currEl.attr('src');

			wx.previewImage({
				current: url,
				urls: urls
			})
		}


		/*  滚动到顶部*/
		$(function() {
			$("#go_top").hide();
		})

		//scroll() 方法为滚动事件  
		$(window).scroll(function() {
			if ($(window).scrollTop() > 100) {
				$("#go_top").fadeIn(800);
			} else {
				$("#go_top").fadeOut(800);
			}
		});

		/* //返回顶部按钮点击
		 $("#go_top").click(function(){
		    $('body,html').animate({scrollTop:0},100);
		    return false;
		 });*/

		function gotottop() {
			$('body,html').animate({
				scrollTop: 0
			}, 100);
			return false;
		}
    //列表点击事件
		function gotodetail(cls) {
			console.log(cls)
			if (cls == 6) {
				window.location = './index.php?mt_id=' + mt_id + '&rd_id=' + rd_id;
			}
			if (cls == 7) {
				window.location = './group.php?mt_id=' + mt_id;
			}

		}

		function gotomain() {
			window.location = './main.php';
		}

		function scrollPosition(pElementId) {
			var tTop = jQuery("#" + pElementId).offset().top; //得到控件Top
			var tWindowHeight = jQuery(window).height(); //浏览器可视窗口高度
			var tElementHeight = jQuery("#" + pElementId).height(); //控件高度
			var tScrollTop = tTop - 126; //让控件中心位于可视窗口3分之1处
			jQuery('html, body').animate({
				scrollTop: tScrollTop
			}, 1000);
		}

		function gotourl(url) {
			window.location = url;
		}
	</script>



	<style>
		.bodyclass {
			overflow: auto;
		}

		.up {
			width: 40px;
			height: 40px;
			position: fixed;
			left: 2vw;
			bottom: 5vw;
		}

		#content_score {
			min-height: 20px;
			padding: 0px 0 0px;
			margin: 0;
		}

		#loadingimg {
			width: 40px;
			height: 40px;
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
			z-index: 999;
		}

		.radius_fillet3 {
			border-radius: 3px;
		}

		.tt_bar {
			height: 30px;
			border-bottom: 1px solid #e3e3e3;
		}

		.score_title2 {
			height: 30px;
			border-bottom: 1px solid #e3e3e3;
			text-indent: 14px;
		}

		.score_back {
			text-align: right;
			padding-right: 14px;
		}

		.bt_back {
			display: inline-block;
			width: 40px;
			height: 18px;
			line-height: 18px;
			cursor: pointer;
			border: 1px solid #363636;
			color: #363636;
			font-size: 12px;
			text-align: center;
		}

		.score_tround {
			height: 30px;
			line-height: 30px;
		}

		.score_tround span {
			color: #363636;
			float: right;
			font-size: 18px;
			height: 26px;
			line-height: 32px;
			margin-right: 15px;
			text-align: center;
			width: 50px;
		}

		.index_news {
			padding: 0 0;
			overflow: scroll;
			height: 100vh;
			margin: 0;
		}
	</style>
	<!--header-->
	<style>
		#navi_wait {
			height: 35px;
			background-color: #E3E3E3;
		}

		#navi_wait ul li {
			width: 32%;
			display: inline;
			float: left;
			/*line-height:33px;*/

			line-height: 36px;
			list-style-position: inside;
			border-bottom: 1px solid #A5A5A5;
			text-align: center;
		}

		#navi_wait ul li a {
			color: #767676;
			font-size: 19px;
			letter-spacing: 5px;
		}

		.scoringtable {
			border-radius: 10px;
			border-collapse: collapse;
			border-style: hidden;
			/*去掉阴影效果*/
			box-shadow: none;
			overflow: hidden;
		}

		.topar {
			width: 90%;
			height: 28px;
			border-radius: 10px;
			margin: auto auto auto auto;
			color: #fff;
			display: flex;
			justify-content: center;
			align-items: center;

		}

		.undereven {
			font-weight: bolder;
			background-color: #B7001F;
			color: #fff;
		}

		.even {
			font-weight: bolder;
			background-color: #53565A;
			color: #fff;
		}

		.pluseven {
			font-weight: bolder;
			background-color: #00438A;
			color: #fff;
		}


		.groupcode {
			display: flex;
			flex-dirction: row;
			float: left;
			align-items: center;
			margin-top: 10px;
			margin-bottom: 5px;
		}

		.groupcode div {
			width: 50px;
			height: 30px;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #000;
			border-radius: 10px;
			margin-left: 10px;
		}

		.full {
			width: 100vw;
			height: 100vh;
			position: fixed;
			left: 0;
			top: 0;
			z-index: 99999;
		}

		.full img {
			width: 100%;
			height: 100%;
			position: absolute;
			object-fit: cover;
		}

		.full .codediv {
			top: 40%;
			left: 50%;
			position: absolute;
			z-index: 100000;
			width: 90%;
			transform: translate(-50%, -50%);
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
		}

		.full .codediv p {
			margin-bottom: 20px;
			text-align: center;
			width: 100%;
			font-size: 20px;
			font-weight: bolder;
		}

		.full .codediv .cn {
			margin-bottom: 20px;
			text-align: center;
			width: 100%;
			font-size: 18px;

		}

		.full .codediv .date {
			margin-bottom: 20px;
			text-align: center;
			width: 100%;
			font-size: 18px;
			color: #cfcfcf;
		}

		.full .codediv .codeinputs {

			width: 90%;
			margin-left: auto;
			margin-right: auto;
			display: flex;
			flex-dirction: row;
			justify-content: center;
			align-items: center;
		}

		.full .codediv .codeinputs input {
			border-radius: 10px;
			width: 50px;
			height: 50px;
			margin-left: auto;
			margin-right: auto;
			border: 1px solid #cfcfcf;
			font-size: 22px;
			font-weight: bolder;
			text-align: center;
		}

		.full .imgsponser {
			top: 20%;
			left: 50%;
			position: absolute;
			z-index: 100000;
			width: 100%;
			height: auto;
			transform: translate(-50%, -50%);
		}

		#sta {
			position: relative;
			z-index: 99;
			height: 80px;
			width: 100%;
			background-color: transparent;
			left: 0;
			top: 0;
		}

		.backhome {
			position: fixed;
			z-index: 1001;

			left: 2vw;
			bottom: 15vw;
		}

		#scoringlists {
			margin-top: 20px;
			overflow-y: scroll;
		}

		.backhome img {
			width: 40px;
			height: 40px;
			border-radius: 100%;
		}

		.menulists {
			display: flex;
			flex-direction: row;
			justify-content: center;
			align-items: center;
			margin-top: 5px;
			margin-bottom: 5px;
		}

		.menulists .menu {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			width: 70px;
			height: 70px;
			background: linear-gradient(180deg, #1067ac 0%, #1067ac 100%);
			color: #ffffff;
			border-radius: 10px;
			margin-left: auto;
			margin-right: auto;
		}

		.menulists .menu img {
			width: 40px;
			height: 40px;
			margin-top: 5px;
		}

		.menulists .menu text {
			display: flex;
			justify-content: center;
			font-size: 12px;
			font-weight: 700;
			color: #fff;
			margin-top: 5px;
			margin-bottom: 5px;
		}

		.bgt {
			/* background: linear-gradient(180deg, #011433 0%, #004d53 100%); */
			background: linear-gradient(180deg, #074c77 0%, #007d6f 100%);
			border-top-right-radius: 10px;
			border-bottom-right-radius: 10px;
			border-top-left-radius: 5px;
			border-bottom-left-radius: 5px;
			height: 40px;
			padding-left: 10px;
		}

		.bgo {
			background: linear-gradient(180deg, #074c77 0%, #007d6f 100%);
			border-top-right-radius: 10px;
			border-bottom-right-radius: 10px;
			border-top-left-radius: 5px;
			border-bottom-left-radius: 5px;
			height: 40px;
			padding-left: 10px;
		}
	</style>
</head>

<body id="body" class="bodyclass">

	<div id="weather" style="position: fixed; top: 60px; right: 10px; background: rgba(255, 255, 255, 0); padding: 10px; border-radius: 5px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);color: white;">
		<p id="weather-info" class="poppin" style="margin: 0;"></p>
	</div>
	<div id="fullloading" class="full" onclick="closefullpre()" style="display:none;">
		<img id="imgfullloading" src="./images/pre.png" />


	</div>
	<div id="sta">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tbody>
				<tr>
					<td style="text-align:center;"><img src="./images/000.png" style="width:350px;height:80px" /></td>
				</tr>
			</tbody>
		</table>
	</div>

	<img id="loadingimg" src="./images/icon_load.gif" style="display:none;" />
	<div id="content_score" style="">
		<div class="pullrefresh" style="display:none;"></div>


		<span style="display:none;" class="backhome"><a href="main.php?mt_id=<?php echo $mt_id ?>&rd_id=<?php echo $rd_id ?>"><img src="./images/home.png" /></a></span>
		<marquee style="margin-top:10px;display:none;" width="100%" align="absmiddle" height="30">
			<font style="color:#B7001F;">由于天黑原因第二轮比赛暂停，比赛将于第二天周四恢复，请各位球员于<b> 07:30 </b>前在出发广场集合，进行开球前准备工作。</font>
		</marquee>
		<div class="index_news">
			<table class="altrowstable scoringtable" style="display:none;">
				<tr>

					<td style="border:none; vertical-align:middle;">
						<div>
							<font style="font-weight:bolder;font-size:17px;"><?php echo str_replace('-', '<br/>', $match_cn_name); ?></font>

						</div>

					</td>
				</tr>
				<tr>
					<td style="border:none; vertical-align:middle;">


						<div style="display:flex;flex-direction:row;justify-content:center;position:relative;">
							<div style="text-align:center;color:#333;font-weight:700;font-size:16px;"> 竞赛规程 </div>

							<div style="display:flex;flex-direction:row;justify-content:center;position:absolute;right:0;top:0;">
								<?php if ($mt_sts == 'N') {
									echo '<font style="float:right;color:#B7001F; font-weight:bolder;font-size:15px;">比赛未开始</font>';
								} else if ($mt_sts == 'O') {
									echo '<font style="float:right;color:#00438A;font-weight:bolder;font-size:15px;">比赛进行中</font>';
								} else {
									echo '<font style="float:right;color:#00438A;font-weight:bolder;font-size:15px;">比赛已结束</font>';
								}								?>
							</div>
						</div>

					</td>
					<td style="border:none; vertical-align:middle;"><span style="" class="bt_back radius_fillet3 back"><a href="index.php?mt_id=<?php echo $mt_id ?>&rd_id=<?php echo $rd_id ?>">返回</a></span></td>

				</tr>
			</table>




			<div id="scoringlists">






			</div>
		</div>



	</div>

	<img src="images/up.png" class="up" id="go_top" onclick="gotottop();">
	<div class="bottommenu">
		<div class="<?php echo $css_class; ?>" onclick="gotomain()"><?php echo t('home_page'); ?></div>
	</div>
	<div id="bottom" style="background-color:#fff;text-align:centre;display:none;justify-content: center;">
		<div id="bootom-top">
			<span style="width:100%;text-align:center">技术支持 @斯科云科技</span>
			<script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
			<script>
				LA.init({
					id: "JfdLQyPJr7gH7CeO",
					ck: "JfdLQyPJr7gH7CeO"
				})
			</script>
		</div>
	</div>
</body>
<script>
	//proloading();

	var pretime = "";

	function proloading() {

		$('#code0').focus();

		let storage = new Storage();
		let value = storage.getItem('ischeked');
		if (value == 1) {
			//console.log("页面直接进入");

			$('#fullloading').hide();
			//$(this).fadeOut("fullloading");
			//console.log($('#fullloading'));
		} else {

			//$('#fullloading').fadeIn();
			let storage = new Storage();
			storage.setItem({
				name: "ischeked",
				value: 1,
				expires: 1 * 24 * 3600 * 1000, //一周 默认
				startTime: new Date().getTime() //记录何时将值存入缓存，毫秒级
			})
			pretime = setTimeout(function() {
				$('#fullloading').fadeOut(2000);

			}, 2000);

		}
	}


	function closefullpre() {
		//console.log($('#fullloading'));
		$('#fullloading').fadeOut(1000);

		clearTimeout(pretime);
	}
</script>

</html>